
CC=gcc
AR=ar

#
# Modify these params if the commands are somewhere else
#

SED=sed
CP=cp
MV=mv
LN=ln -sf
RM=rm -f
CHMOD=chmod

AFC_CFLAGS=`afc-config --cflags`
AFC_LIBS=`afc-config --libs`

# This is a somewhat involved way to get the full path of Python's static library
PYTHON_STATIC=`echo "from distutils import sysconfig; print '%s/%s' % ( sysconfig.get_config_var ( 'LIBPL' ), sysconfig.get_config_var ( 'LDLIBRARY' ) )" | python`

# Needed by libpython
OTHER_LIBS=`echo "from distutils import sysconfig; print '%s %s' % ( sysconfig.get_config_var ( 'LIBS' ), sysconfig.get_config_var ( 'MODLIBS' ) )" | python`

PYTHON_INCLUDE_PATH=`echo "from distutils import sysconfig; print sysconfig.get_python_inc()" | python`

PYTHON_LIBS=$(PYTHON_STATIC) $(OTHER_LIBS)

CFLAGS=-fPIC -g -Wall -O2 $(AFC_CFLAGS)
LIBFLAGS=-shared 

#
# Modify these params to copy files in different locations
#
LIBDIR=/usr/local/lib
BINDIR=/usr/local/bin
INCDIR=/usr/local/include

OBJS=../../base.o ../../string.o ../../array_master.o ../../dynamic_class_master.o ../../dynamic_class.o ../../hash_master.o ../../dictionary.o ../pyconnector.o


all: test01 plugin.so

pyconnector.o: ../pyconnector.c ../pyconnector.h
	@make -f ../Makefile pyconnector.o

test01:	test01.c  $(OBJS)
	@$(CC) $(CFLAGS) -o test01 test01.c -I$(PYTHON_INCLUDE_PATH) $(OBJS) $(PYTHON_LIBS)

plugin.so: plugin.o
	@$(CC) $(LIBFLAGS) -Wl,-soname,plugin.so -o plugin.so plugin.o $(AFC_LIBS)

plugin.o: plugin.c
	@$(CC) -c $(CFLAGS) -o plugin.o plugin.c

clean:
	@$(RM) -f ./*.o
	@$(RM) -f test01
	@$(RM) -f ./*.so

